﻿using System;
using System.Collections.Generic;
using System.Linq;
using Istace.Framework.Mapping.Core;
using Istace.Framework.Mapping.Core.Exceptions;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace Istace.Framework.Mapping.UnitTest
{
    [TestClass]
    public class MappingWithNoMapperRegistered
    {
        [TestMethod]
        [ExpectedException(typeof(MapperNotFoundException), "Method call should throw MapperNotFoundException", AllowDerivedTypes = false)]
        public void CallToMapWithDestinationTypeShouldThrowMapperNotFoundException()
        {
            Mapper.Initialize(this.GetType().Assembly, false, true);
            Mapper.Map<NotMappedType>(new NotMappedType());
        }

        [TestMethod]
        [ExpectedException(typeof(MapperNotFoundException), "Method call should throw MapperNotFoundException", AllowDerivedTypes = false)]
        public void CallToMapWithDestinationAndSourceTypeShouldThrowMapperNotFoundException()
        {
            Mapper.Initialize(this.GetType().Assembly, false, true);
            Mapper.Map<NotMappedType, NotMappedType>(new NotMappedType());
        }

        [TestMethod]
        [ExpectedException(typeof(MapperNotFoundException), "Method call should throw MapperNotFoundException", AllowDerivedTypes = false)]
        public void CallToMapListWithDestinationTypeShouldThrowMapperNotFoundException()
        {
            Mapper.Initialize(this.GetType().Assembly, false, true);
            Mapper.MapList<NotMappedType>(new List<NotMappedType> { new NotMappedType() }).ToList();
        }

        [TestMethod]
        [ExpectedException(typeof(MapperNotFoundException), "Method call should throw MapperNotFoundException", AllowDerivedTypes = false)]
        public void CallToMapListWithDestinationAndSourceTypeShouldThrowMapperNotFoundException()
        {
            Mapper.Initialize(this.GetType().Assembly, false, true);
            Mapper.MapList<NotMappedType, NotMappedType>(new List<NotMappedType> { new NotMappedType() }).ToList();
        }
    }
}
